package cn.edu.zafu.bigdata.lekang.shiyan5;

import java.util.Scanner;

class InvalidScoreException extends Exception {
    public InvalidScoreException(String message) {
        super(message);
    }
}
public class ScoreValidation {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.print("请输入分数: ");
        int score = scanner.nextInt();

        try {
            checkScore(score);
        } catch (InvalidScoreException e) {
            System.out.println("错误: " + e.getMessage());
        }

        scanner.close();
    }

    public static void checkScore(int score) throws InvalidScoreException {
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("分数 " + score + " 无效，必须在0到100之间");
        } else {
            System.out.println("分数 " + score + " 是有效的");
        }
    }
}
